<template>
    <Switch v-model="app.app_enable" size="small" @on-change="handleAppEnableChange(app)" :disabled="!app.app_checked" />
</template>

<script>
export default {
    name: 'AppEnableButton',
    props: {
        data: Object
    },
    data() {
        return {
            app: this.data
        }
    },
    methods: {
        handleAppEnableChange(row) {
            this.$http.post('/app_enable', { app_id: row.app_id, app_enable: row.app_enable ? 1 : 0 }).then(res => {
                if (res.status == 'ok') {
                    this.$Message.success('切换成功');
                } else {
                    this.errorMessage(res.data);
                }
            });
        },
    }
}
</script>